package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class FindOperation implements IOperation{

    @Override
    public void work(BookList book) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你需要查找的书籍名称");
        String bookName = scanner.nextLine();

        //遍历查找
        int size = book.getUsedSize();
        for(int i = 0; i < size; i++){
            Book b = book.getBooks(i);
            if(b.getName().equals(bookName)){
                System.out.println("已经查询到您需要的书籍：");
                System.out.println(b);
                return;
            }
        }

        System.out.println("尚未找到您想要的书籍！");

    }
}
